-
Notifications
You must be signed in to change notification settings - Fork 20
feat: Provider events refactor #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… notifications/requests for each event type.
96f0dd7
to
1a176ae
Compare
1a176ae
to
b26aefb
Compare
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh-blobs/pr/142/docs/iroh_blobs/ Last updated: 2025-09-11T14:49:35Z |
This shows how to limit serving content in various ways - by node id - by content hash - throttling - limiting max number of connections
I took a quick look at the examples and the implementation. It looks very solid overall and is a great improvement especially for power-user usecases. I have yet to look closer to comment on the implementation. I had a closer look at the limits example to see how this will be used. The API is fine, I think! |
My branch had some copy-paste mistakes, sorry for that - fixups are here: 65e5e40 |
68d284d
to
dc2c177
Compare
so the other side can know if reconnecting is OK
Thanks for the DRYing. Cherry-picked it. I think I need to change the GetError a bit. Currently it is a mix of an interpretation of what went wrong and just a flat list of cases. It needs to become either the one or the other. Currently it is hard to get the reset error code back from the GetError since it can hide in so many cases. But I think GetError refactoring is best left for a subsequent PR. |
b84a7cb
to
f399e2b
Compare
@@ -0,0 +1,371 @@ | |||
/// Example how to limit blob requests by hash and node id, and to add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is very cool overall!
pub fn tracing(&self, mask: EventMask) -> Self { | ||
use tracing::trace; | ||
let (tx, mut rx) = tokio::sync::mpsc::channel(32); | ||
n0_future::task::spawn(async move { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no task tracking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was too lazy to make this a full fledged actor. Not sure if it is worth it here.
Description
Refactor provider events into a proper irpc protocol.
Also allow configuring for each event type if the event is sent as a notification, a proper request with answer, or not at all.
Breaking Changes
Provider events completely changed. Other than that the changes should be minimal. You can still create a BlobsProtocol by passing None.
Notes & open questions
Note: to review, best to start with looking at the limit example, then look at the docs.
Change checklist